package io.renren.modules.device.service.impl;

import io.renren.common.annotation.DataFilter;
import io.renren.common.utils.Constant;
import io.renren.modules.device.dao.BuildingDao;
import io.renren.modules.device.entity.BuildingEntity;
import io.renren.modules.sys.shiro.ShiroUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.device.dao.DeviceDataDao;
import io.renren.modules.device.entity.DeviceDataEntity;
import io.renren.modules.device.service.DeviceDataService;


@Service("deviceDataService")
public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataDao, DeviceDataEntity> implements DeviceDataService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        Page<DeviceDataEntity> page = new Query<DeviceDataEntity>(params).getPage();
        EntityWrapper<DeviceDataEntity> wrapper=new EntityWrapper<>();

        if(!ShiroUtils.getUserId().equals(Constant.SUPER_ADMIN)){
            params.put("userId",ShiroUtils.getUserId());
        }


        List<DeviceDataEntity> list = this.baseMapper.selectListPage(page, params);
        page.setRecords(list);

        return new PageUtils(page);
    }


}
